package textapp.dao.model;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@NamedQueries({
	@NamedQuery(name="User.getByIdentity", query="select u from User u where u.identity = :identity")
})

@Entity
@Table(name="userprofile")
public class User {
	
	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "uid", nullable = false)
	private int id;
	
	@Basic(optional = false)
    @Column(name = "name", nullable = false, length = 200)
	private String name;
	
	@Basic(optional = false)
    @Column(name = "identity", nullable = false, length = 200)
	private String identity;
	
	@Column(name="status")
	private int status; // 0 = normal, 1 = not registered user
	
	@Column(name="push_identity")
	private String pushIdentity;
	
	



	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getIdentity() {
		return identity;
	}

	public void setIdentity(String identity) {
		this.identity = identity;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}
	
	public String getPushIdentity() {
		return pushIdentity;
	}

	public void setPushIdentity(String pushIdentity) {
		this.pushIdentity = pushIdentity;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof User)) {
			return false;
		}
		User other = (User) obj;
		if (other.getId() == 0) {
			return false;
		}
		return (this.id == other.getId());
		
	}
	
}
